#ifndef _SMP_COMBOBOX_H
#define _SMP_COMBOBOX_H

#include "sgl_funcs.h"
#include "sgl_window.h"

enum {
	SMP_COMBOBOX_SETSIZE,
	SMP_COMBOBOX_GETSIZE,
	SMP_COMBOBOX_SETITEM,
	SMP_COMBOBOX_GETITEM,
	SMP_COMBOBOX_SETITEMS,
	SMP_COMBOBOX_SETITEMSEX,
	SMP_COMBOBOX_SETSELECTEDITEM,
	SMP_COMBOBOX_GETSELECTEDITEM,
	SMP_COMBOBOX_SHOWCONTENT
	//,SMP_COMBOBOX_WNDPROC
};

#ifndef SDK_NO_PLUGIN
#define SMP_COMBOBOX_WNDPROC  MPS_CODE_SMP_COMBOBOX_PROC
#else
#define SMP_COMBOBOX_WNDPROC  SMP_ComboBox_WndProc
#endif


/**
  \defgroup smp_combobox Simple Combo Box

  To work with the simple combo box:
  - Create the combo box window
  - Set the combo box items and the selected item
  - Add to the parent window
  - Response to the notify message

  \code
  	//create the combo box
  	hCombo = SGL_CreateWindow(SMP_ComboBox_WndProc, ...);
  	SMP_ComboBox_SetItems(hCombo, ...);
  	SMP_ComboBox_SetSelectedItem(hCombo, ...);
  	SGL_AddChildWindow(hWnd, hCombo);

  	//response to the notify message
	case WM_COMMAND:
		WID id = LOWORD(wParam);
		WORD code = HIWORD(wParam);

		if(id == "the combo id" && code == SMP_COMBON_VALUECHANGED)
		{
			int index = (int)lParam; //current selected index
			...
		}	
  \endcode
  
  @ingroup controls
  @{
*/

	/**
	 * \name Window Notify Messages
	 * @{
	 */
	 
/**
 * \brief Combo box value changed notify message.
 *
 * \code
 *	case WM_COMMAND:
 *		WID id = LOWORD(wParam);
 *		WORD code = HIWORD(wParam);
 *
 *		if(id == "the combo id" && code == SMP_COMBON_VALUECHANGED)
 *		{
 *			int index = (int)lParam; // current selected index
 *			...
 *		}
 * \endcode
 *
 * \param index the current selected index
 */

#define SMP_COMBON_VALUECHANGED		0x0001

	/** @} */

	/**
	 * \name Window Member Functions
	 * @{
	 */

#if defined(INCLUDE_IN_PLUG_SGL_SRC) || defined(SDK_NO_PLUGIN)
/**
 * \brief Set the combo box list size.
 *
 * \param hWnd the combo box window handle
 * \param size the list size
 * \return TRUE on success, FALSE otherwise
 */
BOOL SMP_ComboBox_SetSize(HWND hWnd, Sint32 size);

/**
 * \brief Get the combo box list size.
 *
 * \param hWnd the combo box window handle
 * \return the combo list size
 */
Sint32 SMP_ComboBox_GetSize(HWND hWnd);

/**
 * \brief Set the combo box list item information.
 *
 * \param hWnd the combo box window handle
 * \param index the list index
 * \param str the displayed string 
 * \param userdata the user specific data
 */
int32 SMP_ComboBox_SetItem(HWND hWnd, Sint32 index, PCWSTR str, DWORD userdata);

/**
 * \brief Get the combo box list item information.
 *
 * \param hWnd the combo box window handle
 * \param index the item index
 * \param[out] str the displayed string
 * \param[out] userdata the user specific data
 */
int32 SMP_ComboBox_GetItem(HWND hWnd, Sint32 index, PCWSTR * str, DWORD* userdata);

/**
 * \brief Set the combo box list items.
 *
 * This is a wraper function for SMP_ComboBox_SetSize/SMP_ComboBox_SetItem,
 * So if SMP_ComboBox_SetItems used please do not call SMP_ComboBox_SetSize/SMP_ComboBox_SetItem again.
 *
 * \param hWnd the combo box window handle
 * \param items the combo box list items array
 * \param size the items array size
 * \return TRUE on success, FALSE otherwise
 * \sa SMP_ComboBox_SetSize, SMP_ComboBox_SetItem
 */
BOOL SMP_ComboBox_SetItems(HWND hWnd, const DWORD* items, Sint32 size);
BOOL SMP_ComboBox_SetItemsEx(HWND hWnd, const DWORD* items, Sint32 size);
/**
 * \brief Select a item by it's index.
 *
 * \param hWnd the combo box window handle
 * \param index the list item index
 * \param redraw if redraw the combo box
 * \param notify if send notify message
 */
int32 SMP_ComboBox_SetSelectedItem(HWND hWnd, Sint32 index, BOOL redraw, BOOL notify);

/**
 * \brief Get the selected item index.
 *
 * \param hWnd the combo box window handle
 * \return the selected item index
 */
Sint32 SMP_ComboBox_GetSelectedItem(HWND hWnd);

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief Combo box procedure
 *
 * \param hWnd the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
LRESULT SMP_ComboBox_WndProc(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam);

int32 SMP_ComboBox_ShowContentMenu(HWND hWnd);
	/** @} */
#else
/**
 * \brief Set the combo box list size.
 *
 * \param hWnd the combo box window handle
 * \param size the list size
 * \return TRUE on success, FALSE otherwise
 */
#define SMP_ComboBox_SetSize(hWnd, size) \
	(BOOL)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SETSIZE, (int32)hWnd, (int32)size, (int32)0, (int32)0, (int32)0)

/**
 * \brief Get the combo box list size.
 *
 * \param hWnd the combo box window handle
 * \return the combo list size
 */
#define SMP_ComboBox_GetSize(hWnd) \
	(Sint32)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_GETSIZE, (int32)hWnd, (int32)0, (int32)0, (int32)0, (int32)0)

/**
 * \brief Set the combo box list item information.
 *
 * \param hWnd the combo box window handle
 * \param index the list index
 * \param str the displayed string 
 * \param userdata the user specific data
 */
#define SMP_ComboBox_SetItem(hWnd, index, str, userdata) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SETITEM, (int32)hWnd, (int32)index, (int32)str, (int32)userdata, (int32)0)

/**
 * \brief Get the combo box list item information.
 *
 * \param hWnd the combo box window handle
 * \param index the item index
 * \param[out] str the displayed string
 * \param[out] userdata the user specific data
 */
#define SMP_ComboBox_GetItem(hWnd, index, str, userdata) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_GETITEM, (int32)hWnd, (int32)index, (int32)str, (int32)userdata, (int32)0)

/**
 * \brief Set the combo box list items.
 *
 * This is a wraper function for SMP_ComboBox_SetSize/SMP_ComboBox_SetItem,
 * So if SMP_ComboBox_SetItems used please do not call SMP_ComboBox_SetSize/SMP_ComboBox_SetItem again.
 *
 * \param hWnd the combo box window handle
 * \param items the combo box list items array
 * \param size the items array size
 * \return TRUE on success, FALSE otherwise
 * \sa SMP_ComboBox_SetSize, SMP_ComboBox_SetItem
 */
#define SMP_ComboBox_SetItems(hWnd, items, size) \
	(BOOL)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SETITEMS, (int32)hWnd, (int32)items, (int32)size, (int32)0, (int32)0)

#define SMP_ComboBox_SetItemsEx(hWnd, items, size) \
(BOOL)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SETITEMSEX, (int32)hWnd, (int32)items, (int32)size, (int32)0, (int32)0)
/**
 * \brief Select a item by it's index.
 *
 * \param hWnd the combo box window handle
 * \param index the list item index
 * \param redraw if redraw the combo box
 * \param notify if send notify message
 */
#define SMP_ComboBox_SetSelectedItem(hWnd, index, redraw, notify) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SETSELECTEDITEM, (int32)hWnd, (int32)index, (int32)redraw, (int32)notify, (int32)0)

/**
 * \brief Get the selected item index.
 *
 * \param hWnd the combo box window handle
 * \return the selected item index
 */
#define SMP_ComboBox_GetSelectedItem(hWnd) \
	(Sint32)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_GETSELECTEDITEM, (int32)hWnd, (int32)0, (int32)0, (int32)0, (int32)0)

	/** @} */

	/**
	 * \name Window Procedure
	 * @{
	 */

/**
 * \brief Combo box procedure
 *
 * \param hWnd the window handle
 * \param Msg the window message
 * \param wParam the first parameter
 * \param lParam the second parameter
 * \return the result of message process 
 */
#define SMP_ComboBox_WndProc(hWnd, Msg, wParam, lParam) \
	(LRESULT)mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX_PROC, (int32)hWnd, (int32)Msg, (int32)wParam, (int32)lParam, (int32)0, (int32)0)

#define SMP_ComboBox_ShowContentMenu(hWnd) \
	mrc_extSendAppEventEx(MPS_CODE_SMP_COMBOBOX, SMP_COMBOBOX_SHOWCONTENT, (int32)hWnd, (int32)0, (int32)0, (int32)0, (int32)0)
	/** @} */
#endif
	
/** @} end of smp_progbar */

#endif
